OpenBuildings GenerativeComponents Help

Input Arguments

Each function can take input arguments if you define the function to do so. If there are no input arguments in the function definition, the parentheses remain empty both in the function definition and when the function is called. GCScript is a language in which type declarations are optional; however, if we don't use type declarations, the script editors will have a harder time providing accurate auto-completion lists as you're working.

The names of the input arguments in the function definition is only valid within the scope or range of the function definition and is not visible outside the function. Equally, variables that are not defined within the function or passed in as input variables are not guaranteed to be available when the function is called and their use is discouraged. It may work when the function is being defined, but you may later delete a variable on the outside, causing the function relying on it to break.

It is good practice to pass every variable used inside into the function through its input arguments. A function header with multiple input arguments may look like this:

void TestFunction (int numberOfPoints, double scaleFactor, Point
startPoint)
{
    // function definition goes here
}

Subsequently, when call this function, we have to pass it three input values, otherwise there will be an error. Also the types of the inputs have to match the one declared in the function definition above.

So

TestFunction(5, 0.3, point01)

may be a way to call our test function with three inputs, two of them being simple values and the third being a reference to a Point node, point01, that exists in our model.

The FunctionCall node can be very helpful because it automatically defines input properties that correspond to the function arguments. Therefore, those inputs are readily apparent, and can be manipulated just like the inputs of any other node type.